using MicroMsg.Common.Event;
using MicroMsg.Protocol;
using MicroMsg.Resource.@string;
using MicroMsg.Scene;
using MicroMsg.UI.UserContrl;
using MicroMsg.UI.Util;
using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
namespace MicroMsg.UI.Page
{
	public class RegByPhoneStepVoiceCode : BasePage
	{
		private EventWatcher mWatcherPhoneReg;
		private string mCurrentLangName = "en";
		private string mEntryType;
		internal Grid LayoutRoot;
		internal Grid sencondRoot;
		internal panelTitle2Line panelTitle;
		internal StackPanel ContentPanel;
		internal TextBlock textBlock1;
		internal TextBlock textBlock2;
		internal Button btnLang;
		internal TextBlock txtLang;
		internal Button btnVoiceDial;
		private bool _contentLoaded;
		public RegByPhoneStepVoiceCode()
		{
			this.InitializeComponent();
		}
		protected override void OnPageIn(object[] object_0)
		{
			this.txtLang.set_Text("English");
			if (object_0 != null && object_0.Length != 0)
			{
				this.mEntryType = (object_0[0] as string);
			}
			if (this.mWatcherPhoneReg == null)
			{
				this.mWatcherPhoneReg = new EventWatcher(this, null, new EventHandlerDelegate(this.onPhoneAuthRegHandler));
				EventCenter.registerEventWatcher(EventConst.ON_NETSCENE_MOBILE_VOICEDIAL_SUCCESS, this.mWatcherPhoneReg);
				EventCenter.registerEventWatcher(EventConst.ON_NETSCENE_MOBILE_VOICEDIAL_ERR, this.mWatcherPhoneReg);
			}
		}
		protected override void OnPageOut()
		{
			if (this.mWatcherPhoneReg != null)
			{
				EventCenter.removeEventWatcher(EventConst.ON_NETSCENE_MOBILE_VOICEDIAL_SUCCESS, this.mWatcherPhoneReg);
				EventCenter.removeEventWatcher(EventConst.ON_NETSCENE_MOBILE_VOICEDIAL_ERR, this.mWatcherPhoneReg);
				this.mWatcherPhoneReg = null;
			}
		}
		private void onPhoneAuthRegHandler(EventWatcher watcher, BaseEventArgs evtArgs)
		{
			this.enableAllControls();
			if (evtArgs.mEventID == EventConst.ON_NETSCENE_MOBILE_VOICEDIAL_SUCCESS)
			{
				MMMessageBox.Show("", strings.Login_PhoneReg_VoiceCodeSentOK, 1, true, strings.COM_Confirm, "取消");
				base.GoBack();
				return;
			}
			if (evtArgs.mEventID == EventConst.ON_NETSCENE_MOBILE_VOICEDIAL_ERR)
			{
				RetConst retConst = (RetConst)evtArgs.mObject;
				RetConst retConst2 = retConst;
				if (retConst2 != RetConst.MM_ERR_CLIENT)
				{
					return;
				}
				MMMessageBox.Show("", strings.Reg_PhoneV_MsgBadNet, 1, true, strings.COM_Confirm, "取消");
			}
		}
		private void btnLang_Click(object sender, RoutedEventArgs e)
		{
			ToolFunction.GotoPageForUserControl("/Source/UI/LoginViews/RegByPhoneStepVoiceLangSelect.xaml", new object[]
			{
				this.txtLang.get_Text(),
				new DlgSelectVoiceLang(this.onSetLang)
			}, false);
		}
		private void onSetLang(string langName, string langCode)
		{
			if (langCode != null)
			{
				this.txtLang.set_Text(langCode);
			}
			if (langName != null)
			{
				this.mCurrentLangName = langName;
			}
		}
		private void btnVoiceDial_Click(object sender, RoutedEventArgs e)
		{
			this.disableAllControls();
			if (this.mEntryType == "reg")
			{
				ServiceCenter.sceneBindOpMobileForReg.doSceneDialForVerifyCode(this.mCurrentLangName);
				return;
			}
			ServiceCenter.sceneBindMobile.doSceneDialForVerifyCode(this.mCurrentLangName);
		}
		private void enableAllControls()
		{
			ProcessingCover.releaseProgressBar(this.LayoutRoot);
		}
		private void disableAllControls()
		{
			ProcessingCover.getProgressBar(this.LayoutRoot, null, null, false, false, null);
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/UI/LoginViews/RegByPhoneStepVoiceCode.xaml", 2));
			this.LayoutRoot = (Grid)base.FindName("LayoutRoot");
			this.sencondRoot = (Grid)base.FindName("sencondRoot");
			this.panelTitle = (panelTitle2Line)base.FindName("panelTitle");
			this.ContentPanel = (StackPanel)base.FindName("ContentPanel");
			this.textBlock1 = (TextBlock)base.FindName("textBlock1");
			this.textBlock2 = (TextBlock)base.FindName("textBlock2");
			this.btnLang = (Button)base.FindName("btnLang");
			this.txtLang = (TextBlock)base.FindName("txtLang");
			this.btnVoiceDial = (Button)base.FindName("btnVoiceDial");
		}
	}
}
